package com.ror.java.se.thread;

//static void yield() 出让线程/礼让线程
//出让当前CPU的执行权，让线程的执行尽可能均匀一些

public class Demo05 {
    public static void main(String[] args) {
        MyRun mr = new MyRun();
        Thread t1 = new Thread(mr,"飞机");
        t1.start();
        Thread t2 = new Thread(mr,"坦克");
        t2.start();
    }

    private static class MyRun implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread().getName() + ": " + i);
                Thread.yield();
            }
        }
    }
}
